package com.ml.mall.api.deduct;

import com.ml.mall.bean.base.ApiRestResult;
import com.ml.mall.bean.req.deduct.DeductEditDto;
import com.ml.mall.consts.PermissionConst;
import com.ml.mall.service.deduct.SysADeductService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 *   @description    :description 
 *   @author         :zxm
 *   @date           :2021/5/19
 *   @version        :1.0
**/
@Api(tags = "【auth】系统提成类型相关接口")
@RestController
@RequestMapping("/deduct")
public class DeductController {

    @Autowired
    private SysADeductService sysADeductService;

    @ApiOperation(value = "系统提成费率")
    @PostMapping("/edit")
//  @RequiresPermissions(PermissionConst.DEDUCT_EDIT)
    public ApiRestResult deductEdit(@RequestBody @Valid DeductEditDto dto){
        sysADeductService.handleDeduct(dto);
        return ApiRestResult.ok();
    }

    @ApiOperation(value = "系统提成查询")
    @PostMapping("/query")
//  @RequiresPermissions(PermissionConst.DEDUCT_QUERY)
    public ApiRestResult deductQuery(){
        return ApiRestResult.ok(sysADeductService.selectCurDeduct());
    }
}
